Imports System.Data

Partial Class SignIn
    Inherits System.Web.UI.Page

    Protected Sub SignIn_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SignIn_btn.Click
        Call Login()
    End Sub

    Protected Sub Logo_btn_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Logo_btn.Click
        Call Login()
    End Sub

    Private Sub Login()
        Dim dm As New DAOMain.CommonDAO

        dm.AddParameter(Username_txt.Text)
        dm.AddParameter(Password_txt.Text)

        Dim dt As DataTable = dm.ExecQryProc("sp_user_login")

        If dt.Rows.Count > 0 Then
            Session.Add("UserName", Username_txt.Text)
            If dt.Rows(0)("advisor_tag") <> "0" Then
                Session.Add("advisor", "1")
            End If
            Response.Redirect("~/Default.aspx")
        Else
            Dim polyfunc As New PolyFunc.ASPFunc

            polyfunc.MessageAlert(Me, "Invalid Username/Password")

            polyfunc = Nothing
        End If

        dm = Nothing
    End Sub
End Class
